MODULES = pi0pi0_hbook.so

EXECUTABLES = 

KUMACS = $(wildcard kumac/*.kumac)
MNF = $(wildcard mnf/*.mnf)

all: $(MODULES) $(EXECUTABLES)
mods : $(MODULES)
exes : $(EXECUTABLES)

LIBS = -L$(BELLE_RUN_DIR)/lib/so -ltuple -lip -lkid -leid -lparticle \
       -lkfitter -lbenergy -lbelleCLHEP -L$(HOME)/lib -lhdf5 -lcrypt -lm \
       -lgcc
SOFLAGS = -shared -Wl,-export-dynamic

CPPFLAGS = -DHAVE_LIBCURSES=1 -DHAVE_LIBREADLINE=1 -DHAVE_POSTGRES=1 \
	   -DHAVE_LIBCURSES=1 -DHAVE_LIBTERMCAP=1 -DHAVE_LIBHISTORY=1 \
           -DHAVE_LIBREADLINE=1 -DHAVE_HISTORY=1 -DHAVE_LIBBSD=1 \
           -DHAVE_LIBM=1 -DHAVE_LIBDL=1 -DHAVE_LIBNSL=1 -DHAVE_LIBCRYPT=1 \
	   -DHAVE_LIBNSL=1 -DHAVE_LIBDL=1 -DFORTRAN_PPU=1 -DHAVE_LIBCRYPT=1 \
           -DCERNLIB_TYPE -DHEP_SHORT_NAMES -DBELLE_SHORT_NAMES \
           -DDSTXX_NOINLINE -DBELLE_TARGET_H=\"belle-default.h\" \
	   -fPIC -O3

INCLUDE = -I$(BELLE_TOP_DIR)/include -I$(HOME)/include \
          -I$(MY_TOP_DIR)/include -I. 


DAFEXE=daf/bin/hbmerge daf/bin/hbread_cb

daf: $(DAFEXE)
	$(MAKE) --directory=$@

%.so : %.o
	g++ $(SOFLAGS) -o $@ $< $(LIBS) 

%.o : %.cc
	g++ -c $^ $(CPPFLAGS) $(INCLUDE)


install: $(MODULES) $(EXECUTABLES) 
	/usr/bin/install $(MODULES) $(BELLEMY)/basf_modules
	/usr/bin/install scripts/*sh $(BELLEMY)/scripts
#	/usr/bin/install $(EXECUTABLES) $(MY_TOP_DIR)/bin	

.PHONY: clean kumac mnf

clean: 
	rm $(MODULES) $(patsubst %.so,%.o,$(MODULES)) *~

kumac:
	/usr/bin/install $(KUMACS) $(BELLEKUMAC)
mnf:
	/usr/bin/install $(MNF) $(BELLEMNF)
